<?php
/**
 * Factory and some commom methods for the virtual file system
 */
class VFS {
    
    /**
     * Error in the connect
     */
    const ERROR_CONNECT = 1;
    
    /**
     * Error in the login
     */
    const ERROR_LOGIN = 2;
    
    /**
     * If using php-gtk
     */
    public $gtk;
    
    /**
     * The server name
     */
    public $server;
    
    /**
     * Username on the server
     */
    public $username
    
    /**
     * Password on the server
     */
    public $password
    
    /** 
     * Private constructor, used by the children, use factory to create a instance of this class
     */
    private function __construct($args)
    {
        $this->server = $args["server"];
        $this->username = $args["username"];
        $this->password = $args["password"];
        $this->gtk = $args["gtk"];
    }
        
    /**
     * Factory, builds a instance of a specialized class
     */
    public static function factory($args)
    {
        if (include_once dirname(__FILE__) . '/' . $args["type"] . '.php') {
            $classname = 'VFS_' . $type;
            return new $classname($args);
        } else {
            throw new Exception ('This type of filesystem is not suported');
        }
    }
}
?> 